<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <?php if ($success) { ?>
  <div class="success"><?php echo $success; ?></div>
  <?php } ?>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/order.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons"><a onclick="location = '<?php echo $insert; ?>'" class="button"><?php echo $button_insert; ?></a></div>
    </div>
    <div class="content">
        <table class="list">
          <thead>
            <tr>
              <td class="center"><?php echo $column_category_name; ?></td>
              <td class="center"><?php echo $column_category_display_name; ?></td>
              <td class="center"><?php echo $column_language; ?></td>
              <td class="center"><?php if ($sort == 'k.keyword') { ?>
                <a href="<?php echo $sort_keyword; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_keyword; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_keyword; ?>"><?php echo $column_keyword; ?></a>
                <?php } ?></td>
              <td class="center"><?php if ($sort == 'k.click_num') { ?>
                <a href="<?php echo $sort_click_num; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_click_num; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_click_num; ?>"><?php echo $column_click_num; ?></a>
                <?php } ?></td>
              <td class="center"><?php if ($sort == 'k.show_home') { ?>
                <a href="<?php echo $sort_show_home; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_show_home; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_show_home; ?>"><?php echo $column_show_home; ?></a>
                <?php } ?></td>
              <td class="center"><?php if ($sort == 'k.status') { ?>
                <a href="<?php echo $sort_status; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_status; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_status; ?>"><?php echo $column_status; ?></a>
                <?php } ?></td>
              <td class="center"><?php echo $column_action; ?></td>
            </tr>
          </thead>
          <tbody>
            <tr class="filter">
              <td class="left"></td>
              <td class="left">
              	<select name="filter_category_id">
              	  <option value="0"><?php echo $text_all; ?></option>
                  <?php foreach ($categories as $category) { ?>
                  <option value="<?php echo $category['category_id']; ?>" title="<?php echo $category['name']; ?>" <?php if($category['category_id'] == $filter_category_id){ echo 'selected="selected"';} ?>><?php echo $category['display_name']; ?></option>
                  <?php } ?>
                </select>
              </td>
              <td class="left">
              	<select name="filter_language_id">
              	  <option value="0"><?php echo $text_all; ?></option>
                  <?php foreach ($languages as $language) { ?>
                  <option value="<?php echo $language['language_id']; ?>" title="<?php echo $language['code']; ?>" <?php if($language['language_id'] == $filter_language_id){ echo 'selected="selected"';} ?>><?php echo $language['name']; ?></option>
                  <?php } ?>
                </select>
              </td>
              <td class="left"><input type="text" name="filter_keyword" value="<?php echo $filter_keyword; ?>" /></td>
              <td class="left"></td>
              <td class="left">
                <input type="radio" name="filter_show_home" value="-1" <?php if ($filter_show_home == -1){ echo 'checked="checked"';} ?> /><?php echo $text_all; ?>
              	<input type="radio" name="filter_show_home" value="0" <?php if ($filter_show_home == 0){ echo 'checked="checked"';} ?> /><?php echo $text_no; ?>
                <input type="radio" name="filter_show_home" value="1" <?php if ($filter_show_home == 1){ echo 'checked="checked"';} ?> /><?php echo $text_yes; ?>
              </td>
              <td class="left">
                <input type="radio" name="filter_status" value="-1" <?php if ($filter_status == -1){ echo 'checked="checked"';} ?> /><?php echo $text_all; ?>
              	<input type="radio" name="filter_status" value="0" <?php if ($filter_status == 0){ echo 'checked="checked"';} ?> /><?php echo $text_status_no; ?>
                <input type="radio" name="filter_status" value="1" <?php if ($filter_status == 1){ echo 'checked="checked"';} ?> /><?php echo $text_status_yes; ?>
              </td>
              <td align="right"><a onclick="filter();" class="button"><?php echo $button_filter; ?></a></td>
            </tr>
            <?php if ($keywords) { ?>
            <?php foreach ($keywords as $keyword) { ?>
            <tr>
              <td class="left"><?php echo $keyword['category_name']; ?></td>
              <td class="left"><?php echo $keyword['category_display_name']; ?></td>
              <td class="left"><img src="view/image/flags/<?php echo $keyword['language_image']; ?>"/>&nbsp;&nbsp;<?php echo $keyword['language_name']; ?></td>
              <td class="left"><?php echo $keyword['keyword']; ?></td>
              <td class="left"><?php echo $keyword['click_num']; ?></td>
              <td class="left">
              	<?php if ($keyword['show_home'] == 1) { echo $text_yes;} else { echo $text_no; } ?>
              </td>
              <td class="left">
              	<?php if ($keyword['status'] == 1) { echo $text_status_yes;} else { echo $text_status_no; } ?>
              </td>
              <td class="right"><?php foreach ($keyword['action'] as $action) { ?>
                [ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ]
                <?php } ?></td>
            </tr>
            <?php } ?>
            <?php } else { ?>
            <tr>
              <td class="center" colspan="8"><?php echo $text_no_results; ?></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
      <div class="pagination"><?php echo $pagination; ?></div>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
function filter() {
	url = 'index.php?route=sale/keyword&token=<?php echo $token; ?>';
	var filter_category_id = $('select[name=\'filter_category_id\'] option:selected').attr('value');
	if (filter_category_id > 0) {
		url += '&filter_category_id=' + filter_category_id;
	}
	var filter_language_id = $('select[name=\'filter_language_id\'] option:selected').attr('value');
	if (filter_language_id > 0) {
		url += '&filter_language_id=' + filter_language_id;
	}
	var filter_keyword = $('input[name=\'filter_keyword\']').attr('value');
	if (filter_keyword) {
		url += '&filter_keyword=' + encodeURIComponent(filter_keyword);
	}
	var filter_status = $('input[name=\'filter_status\']:checked').attr('value');
	if (filter_status != -1) {
		url += '&filter_status=' + filter_status;
	}	
	var filter_show_home = $('input[name=\'filter_show_home\']:checked').attr('value');
	if (filter_show_home != -1) {
		url += '&filter_show_home=' + filter_show_home;
	}
	location = url;
}
//--></script>
<script type="text/javascript"><!--
$('#form input').keydown(function(e) {
	if (e.keyCode == 13) {
		filter();
	}
});
//--></script>
<?php echo $footer; ?>